package edu.jd.movieplatform.user.ticket.dao;

import edu.jd.movieplatform.user.ticket.*;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.springframework.web.bind.annotation.DeleteMapping;

import java.util.List;

public interface TicketDao {
    @Insert("insert into ticket(mov_id, cnm_hall_id, order_num, cnm_id, mov_name, price, " +
            "seat_row, seat_column, screen_time)" +
            "values(#{mov_id},#{cnm_hall_id},#{order_num},#{cnm_id},#{mov_name},#{price}," +
            "#{seat_row},#{seat_column},#{screen_time})")
    public void insertTicket(Ticket ticket);

    @Select("select tick_num, seat_row, seat_column from ticket where order_num = #{order_num}")
    public List<TicketDto> getTicket_num(int order_num);

    @Insert("insert into ticket_temp" +
            "(cust_username, order_time, mov_id, cnm_hall_id, cnm_id, mov_name, " +
            "price, seat_row, seat_column, screen_time)" +
            "values(#{cust_username},#{order_time},#{mov_id},#{cnm_hall_id},#{cnm_id}," +
            "#{mov_name},#{price},#{seat_row},#{seat_column},#{screen_time})")
    public void insertTemp(Ticket_temp temp);

    @Select("select * from ticket_temp where cust_username = #{username}")
    public List<Ticket_temp> findTemp(String username);

    @Delete("delete from ticket_temp " +
            "where seat_row = #{seat_row} and seat_column = #{seat_column} " +
            "and cust_username = #{cust_username}")
    public void deleteTemp(Ticket_temp temp);

    @Delete("delete from ticket_temp where cust_username = #{cust_username}")
    public void deleteAllTempByUsername(String cust_username);

    @Select("select distinct seat_row, seat_column from ticket " +
            "where cnm_id = #{cnm_id} and cnm_hall_id = #{cnm_hall_id} " +
            "and screen_time = #{screen_time}")
    public List<SeatDto> findSelectedSeat(SeatQueryDto dto);

    public List<Ticket> getTicketsByUsername(String username);
}
